



<body>

<!--Search Area  -->	  
  <div class="body" id="user_root">
	<fieldset>
			<legend>查询条件</legend>
			<form id="user_search">
				<table>
				<tr class="prop">
					<td valign="top" class="name" width="18%">
	                   <label for="name">Name:</label>
	                </td>
	                <td valign="top" width="32%">
	                   <input type="text" name="name_mask" id="item_name" onkeydown="doSearch(arguments[0]||event)" />
	                	<input type="checkbox" id="autosearch" onclick="enableAutosubmit(this.checked)">
						允许自动搜索 <br/>
	                </td>
				</tr>
				<tr class="prop">
					<td valign="top" class="name" width="18%">
	                   <label for="name">Name2:</label>
	                </td>
	                <td valign="top"  width="32%">
	                  <input type="text" id="item_name2" name="name_mask2" onkeydown="doSearch(arguments[0]||event)" />
	                </td>
				</tr>
				</table>
			<!--Button Area -->		
			<div id='user_buttons' class="buttons" align="right">
                <input  id="user_button_search" name="2" type="button" value="查询" class="formbutton" />
                <input type="reset" value="重置" class="formbutton" />
               	<input  id="user_button_create" type="button" value="新建" class="formbutton" name="1" />
               	<input  id="user_button_edit" type="button" value="修改" class="formbutton" name="3" />
                <input  id="user_button_view" type="button" value="详细" class="formbutton" name="5"/>
                <input  id="user_button_delete" type="button" value="删除" class="formbutton" name="4"/>
            </div>						
			<!--Button Area end-->					
	</form>
	</fieldset>
<!--Search Area end-->	

<!--List Area -->
           
     <div id="user_list">
		 <table id="user_list2" class="scroll" cellpadding="0" cellspacing="0"></table> 
		 <div id="user_pager2" class="scroll" style="text-align:center;"></div> 
	 </div>		
	
<!--List Area end -->	
	
<!--dialog Area -->
 <div id="user_dialog">
	<input type="hidden" id="user_id" value=""/>
	<input type="hidden" id="user_action" value=""/>
	<form id="user_dailog_form">
                  <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name" width="18%">
                                    <label for="username">Username:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:userInstance,field:'username','errors')}" width="32%">
                                    <input type="text" id="user_username" name="username" value="${fieldValue(bean:userInstance,field:'username')}"/>
                                </td>
						
                                <td valign="top" class="name" width="18%">
                                    <label for="userRealName">User Real Name:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:userInstance,field:'userRealName','errors')}" width="32%">
                                    <input type="text" id="user_userRealName" name="userRealName" value="${fieldValue(bean:userInstance,field:'userRealName')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name" width="18%">
                                    <label for="passwd">Passwd:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:userInstance,field:'passwd','errors')}" width="32%">
                                    <input type="text" id="user_passwd" name="passwd" value="${fieldValue(bean:userInstance,field:'passwd')}"/>
                                </td>
						
                                <td valign="top" class="name" width="18%">
                                    <label for="enabled">Enabled:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:userInstance,field:'enabled','errors')}" width="32%">
                                    <g:checkBox id="enabled" name="enabled" value="${userInstance?.enabled}" ></g:checkBox>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name" width="18%">
                                    <label for="description">Description:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:userInstance,field:'description','errors')}" width="32%">
                                    <input type="text" id="user_description" name="description" value="${fieldValue(bean:userInstance,field:'description')}"/>
                                </td>
						
                                <td valign="top" class="name" width="18%">
                                    <label for="email">Email:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:userInstance,field:'email','errors')}" width="32%">
                                    <input type="text" id="user_email" name="email" value="${fieldValue(bean:userInstance,field:'email')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name" width="18%">
                                    <label for="emailShow">Email Show:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:userInstance,field:'emailShow','errors')}" width="32%">
                                    <g:checkBox id="emailShow" name="emailShow" value="${userInstance?.emailShow}" ></g:checkBox>
                                </td>
						
                                <td valign="top" class="name" width="18%">
                                    <label for="pass">Pass:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:userInstance,field:'pass','errors')}" width="32%">
                                    <input type="text" name="pass" id="user_pass" value="${fieldValue(bean:userInstance,field:'pass')}" />
                                </td>
                            </tr> 
                        
                        </tbody>
                    </table>
              </form>
 </div>
	
<!--dialog Area end -->	


</div>

</body>

<!--js area -->		
			<script type="text/javascript"><!--
		jQuery(document).ready(function(){
		  var	allFields=jQuery('#user_dailog_form input');
				allFields.val();
			//jQuery(allFields).each(function(){alert(jQuery(this).attr('id'));});
		  var	tips = jQuery("#user_validateTips");
				jQuery("#user_dialog").dialog({
				title: '创建***',
				bgiframe: true,
				autoOpen: false,
				height: 300,
				width:600,
				position:'top',
				modal: true,
				buttons: {
					'Save': function() {
						var bValid = true;
						var params ;
						var id=jQuery('#user_id').val();
						var action=jQuery('#user_action').val();
						params= jQuery('#user_dailog_form').serialize()+'&id='+id;
						allFields.removeClass('ui-state-error');
						
						if (bValid) {
							//ajax save
							if(action=='c'){
									jQuery.post('user/save',params,function(s){});
							}
							if(action=='u')

							{
								jQuery.post('user/update',params,function(s){});
							}
							if(action=='v')
								jQuery(this).dialog('close');
							jQuery(this).dialog('close');
							gridReload();
						}
					},
					'Cancel': function() {
						jQuery(this).dialog('close');
					}
				},
				close: function() {
					allFields.val('').removeClass('ui-state-error');
				}
			});
			//open
			
			
			//button click	
		    jQuery('#user_buttons :button').click(function(){
				var index=0;
				index=parseInt(jQuery(this).attr('name'));
			
				switch(index)
				{
				//create
				case 1:
					jQuery('#user_id').val();
					jQuery('#user_action').val('c');
					jQuery('#user_dialog').dialog('option', 'title', '新建');
					jQuery('#user_dialog').dialog('open');
					
				break;
				//inquery
				case 2:
					gridReload();
				break;
				//update
				case 3:
					//jQuery('user_dailog_form #id').val(1);
					jQuery('#user_action').val('u');
					jQuery('#user_dialog').dialog('option', 'title', '编辑');
					doShow();
					jQuery('#user_dialog').dialog('open');
				break;
				//delete
				case 4: 
					if(confirm('确定删除数据？'))
					{
						
						jQuery.post('user/delete',{id:jQuery('#user_id').val()},function(s){
								
								if(s){
									alert("删除成功！");
									gridReload();	
									}
								else
									{alert("删除失败！");}
								gridReload();			
							});	
					}
					
				break;
				//view
				case 5:
					jQuery('#user_action').val('v');
					jQuery('#user_dialog').dialog('option', 'title', '查看');
					doShow();
					jQuery('#user_dialog').dialog('open');
					
				break;	
				default:
					alert('default');
				break;
				};
		    }).hover(
					function(){ 
						jQuery(this).addClass("ui-state-hover"); 
					},
					function(){ 
						jQuery(this).removeClass("ui-state-hover"); 
					}
				).mousedown(function(){
					jQuery(this).addClass("ui-state-active"); 
				})
				.mouseup(function(){
						jQuery(this).removeClass("ui-state-active");
				});
		function doShow()
			{
			     jQuery.post('user/show',{id:jQuery('#user_id').val()},function(json){

			    	 
							jQuery('#user_username').val(json.username);
						
							jQuery('#user_userRealName').val(json.userRealName);
						
							jQuery('#user_passwd').val(json.passwd);
						
							jQuery('#user_enabled').val(json.enabled);
						
							jQuery('#user_authorities').val(json.authorities);
						
							jQuery('#user_description').val(json.description);
						
							jQuery('#user_email').val(json.email);
						
							jQuery('#user_emailShow').val(json.emailShow);
						
							jQuery('#user_pass').val(json.pass);
						
			     },'json');
					  
			};
	//List 
	jQuery("#user_list2").jqGrid({
				url: 'user/jsonList',
				//width:1200,
				datatype:"json",
				colNames:[ 
		                         'authorities',//width:auto
								
		                         'description',//width:auto
								
		                         'email',//width:auto
								
		                         'emailShow',//width:auto
								
		                         'enabled',//width:auto
								
		                         'id',//width:auto
								
		                         'pass',//width:auto
								
		                         'passwd',//width:auto
								
		                         'userRealName',//width:auto
								
		                         'username'//width:auto
								],
				colModel:[
						{name:'id',index:'id', width:55, sortable:true,hidden:true},
						 
                         {name:'authorities',index:'authorities', sortable:true},//width:auto
						
                         {name:'description',index:'description', sortable:true},//width:auto
						
                         {name:'email',index:'email', sortable:true},//width:auto
						
                         {name:'emailShow',index:'emailShow', sortable:true},//width:auto
						
                         {name:'enabled',index:'enabled', sortable:true},//width:auto
						
                         {name:'pass',index:'pass', sortable:true},//width:auto
						
                         {name:'passwd',index:'passwd', sortable:true},//width:auto
						
                         {name:'userRealName',index:'userRealName', sortable:true},//width:auto
						
                         {name:'username',index:'username', sortable:true}//width:auto
						
						],
				rowNum:10,
				rowList:[10,20,50],
				height:250,
				autowidth: true,
				rownumbers: true,
				imgpath: "${resource(dir:'js/images', file:'')}",
				pager: jQuery('#user_pager2'), 
				sortorder: 'asc',
				sortname: 'name',
				viewrecords: true,
				caption:"查询结果",
				onSelectRow:function(id){
								
							    var rd=jQuery('#user_list2').getRowData(id); 
								
								jQuery('#user_id').val(rd.id);
				}
				
				}).navGrid('#user_pager2',{edit:false,add:true,del:false});		
			});
				var timeoutHnd;
				var flAuto = false;
				function doSearch(ev){
					if(!flAuto)
						return;
					// var elem = ev.target||ev.srcElement;
					if(timeoutHnd)
						clearTimeout(timeoutHnd);
					timeoutHnd = setTimeout(gridReload,500);
				}
				function gridReload(){
					var params=jQuery('#user_search').serialize();
					
					jQuery("#user_list2").setGridParam({url:"user/jsonList?"+params,page:1}).trigger("reloadGrid");
				}
				function enableAutosubmit(state){
					flAuto = state;
					jQuery("#user_button_search").attr("disabled",state);
				}

			
							
			--></script>
<!--js area end -->	

